package com.cdtye.shuoh.config.netty;

import com.cdtye.shuoh.util.text.DataConverter;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 编码器
 */
public class MyEncoder extends MessageToByteEncoder<String> {
    private final Logger logger = LoggerFactory.getLogger(MyEncoder.class);
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, String s, ByteBuf byteBuf) throws Exception {
        logger.info("回应消息"+s);
        byteBuf.writeBytes(DataConverter.hexString2Bytes(s));
    }
}
